package com.niuniu.rushdorm.controller;

import com.niuniu.rushdorm.mapper.SysMapper;
import com.niuniu.rushdorm.pojo.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Meng
 * 2022/11/24
 */
@RestController
@RequestMapping(value = "/sys",produces = "application/json;charset=utf-8")
public class SysController {
    @Autowired
    SysMapper sysMapper;
    @GetMapping("/opentime")
    ResultVO openTime(){
        String start_time = sysMapper.getConfigValue("start_time");
        String end_time = sysMapper.getConfigValue("end_time");
        Map<String,String> dataMap = new HashMap<>();
        dataMap.put("start_time",start_time);
        dataMap.put("end_time",end_time);
        return ResultVO.success(dataMap);
    }
    @GetMapping("/classlimit")
    ResultVO classLimit(){
        String class_limit = sysMapper.getConfigValue("class_limit");
        Map<String,String> dataMap = new HashMap<>();
        dataMap.put("class_limit",class_limit);
        return ResultVO.success(dataMap);
    }
    @GetMapping("/groupnum")
    ResultVO groupNum(){
        String group_limit = sysMapper.getConfigValue("group_limit");
        String group_num = sysMapper.getConfigValue("group_num");
        Map<String,String> dataMap = new HashMap<>();
        dataMap.put("group_limit",group_limit);
        dataMap.put("group_num",group_num);
        return ResultVO.success(dataMap);
    }

}
